notification.setTransient(true);
source.notify(notification);
}
+
+// killall:
+// @processName: a process name
+//
+// Kills @processName. If no process with the given name is found,
+// this will fail silently.
+function killall(processName) {
+ try {
+ // pkill is more portable than killall, but on Linux at least
+ // it won't match if you pass more than 15 characters of the
+ // process name... However, if you use the '-f' flag to match
+ // the entire command line, it will work, but we have to be
+ // careful in that case that we can match
+ // '/usr/bin/processName' but not 'gedit processName.c' or
+ // whatever...
+
+ let argv = ['pkill', '-f', '^([^ ]*/)?' + processName + '($| )'];
+ GLib.spawn_sync(null, argv, null, GLib.SpawnFlags.SEARCH_PATH, null, null);
+ // It might be useful to return success/failure, but we'd need
+ // a wrapper around WIFEXITED and WEXITSTATUS. Since none of
+ // the current callers care, we don't bother.
+ } catch (e) {
+ logError(e, 'Failed to kill ' + processName);
+ }
+}
const Main = imports.ui.main;
const MessageTray = imports.ui.messageTray;
const Params = imports.misc.params;
+const Util = imports.misc.util;
let nextNotificationId = 1;
log('Failed to acquire org.freedesktop.Notifications');
else {
log('Failed to acquire org.freedesktop.Notifications; trying again');
-
- // kill the notification-daemon. pkill is more portable
- // than killall, but on Linux at least it won't match if
- // you pass more than 15 characters of the process name...
- // However, if you use the '-f' flag to match the entire
- // command line, it will work, but we have to be careful
- // in that case that we don't match 'gedit
- // notification-daemon.c' or whatever...
- let p = new Shell.Process({ args: ['pkill', '-f',
- '^([^ ]*/)?(notification-daemon|notify-osd)$']});
- p.run();
+ Util.killall('notification-daemon');
+ Util.killall('notify-osd');
}
},
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
const Gio = imports.gi.Gio;
-const GLib = imports.gi.GLib;
const DBus = imports.dbus;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
_checkError: function(error) {
if (!this._restarted && error && error.message.match(/org\.freedesktop\.DBus\.Error\.(UnknownMethod|InvalidArgs)/)) {
- GLib.spawn_command_line_sync('pkill -f "^gnome-power-manager$"');
+ Util.killall('gnome-power-manager');
Util.spawn(['gnome-power-manager']);
this._restarted = true;
}
const MessageTray = imports.ui.messageTray;
const NotificationDaemon = imports.ui.notificationDaemon;
+const Util = imports.misc.util;
const STANDARD_TRAY_ICON_IMPLEMENTATIONS = {
'bluetooth-applet': 'bluetooth',
// app-indicators, so that applications fall back to normal
// status icons
// http://bugzilla.gnome.org/show_bug.cgi=id=621382
- let p = new Shell.Process({ args: ['pkill', '-f', '^([^ ]*/)?indicator-application-service$']});
- p.run();
+ Util.killall('indicator-application-service');
},
_onTrayIconAdded: function(o, icon) {